package com.fun.feifun.modules.business.model.param;

import com.fun.feifun.base.BaseEntity;
import com.fun.feifun.base.utils.MD5Util;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import lombok.experimental.Accessors;

/**
 * <p>
 * 系统用户
 * </p>
 *
 * @author wkf
 * @since 2024-06-04
 */
@Data
@Accessors(chain = true)
public class BusinessPlaceOrderParam  {

    private static final long serialVersionUID=1L;

    @ApiModelProperty(value = "用户编码",required = true)
    @NonNull
    private String userid;

    @ApiModelProperty(value = "商品编码",required = true)
    @NonNull
    private String productid;

    @ApiModelProperty(value = "充值金额（面值）整数 （需要和商品金额一致）",required = true)
    @NonNull
    private Integer price;

    @ApiModelProperty(value = "商品数量")
    @NonNull
    private Integer num;

    @ApiModelProperty(value = "充值目标账号(手机号)",required = true)
    @NonNull
    private String mobile;

    @ApiModelProperty(value = "代理商订单时间，(yyyyMMddHHmmss)如20210224134552",required = true)
    @NonNull
    private String spordertime;

    @ApiModelProperty(value = "代理商系统订单号")
    @NonNull
    private String sporderid;

    @ApiModelProperty(value = "密匙",required = true)
    @NonNull
    private String key;

    @ApiModelProperty(value = "回调接口地址",required = true)
    private String back_url;


    public BusinessPlaceOrderParam() {

    }
    @ApiModelProperty(value = "签名验证摘要串：MD5(userid=xxx&productid=xxx&mobile=xxx&price=xxx&&key=xxxspordertime&&=xxx)",required = true)
    @NonNull
    private String sign;
    public String MD5Sign() {
        String encrypt ="";
        try {
            StringBuilder signStr = new StringBuilder();
            signStr.append("userid="+this.getUserid()+"&&");
            signStr.append("productid="+this.getProductid()+"&&");
            signStr.append("mobile="+this.getMobile()+"&&");
            signStr.append("price="+this.getPrice()+"&&");
            signStr.append("key="+this.getKey()+"&&");
            signStr.append("spordertime="+this.getSpordertime());
            encrypt = MD5Util.encrypt(signStr.toString());
        }catch (Exception e){
            e.printStackTrace();
        }
        return encrypt;
    }
}
